package com.qk.mapper;

import com.qk.entity.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface RoleMapper {
    // 增
    @Insert("insert into role(name, label, remark, create_time, update_time) values(#{name}, #{label}, #{remark}, #{createTime}, #{updateTime})")
    void insert(Role role);

    // 删
    @Delete("delete from role where id = #{id}")
    void deleteById(Integer id);

    // 改
    void update(Role role);

    // 查 -- 分页
    List<Role> selectList(String name, String label);

        // 查 -- 根据ID
    @Select("select id, name, label, remark, create_time, update_time from role where id = #{id}")
    Role selectById(Integer id);

        // 查 -- 查所有角色
    @Select("select id, name, label, remark, create_time, update_time from role ORDER BY update_time DESC")
    List<Role> getAllRoles();
}
